package com.neu.af.dataFilter.service.impl;

import com.neu.af.common.exception.BusinessException;
import com.neu.af.dataFilter.entity.Data;
import com.neu.af.dataFilter.mapper.DataMapper;
import com.neu.af.dataFilter.service.DataService;
import com.neu.af.util.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("dataService")
public class DataServiceImpl implements DataService {
    @Autowired
    DataMapper dataMapper;

    @Override
    public int insert(Data data) {
        return dataMapper.insert(data);
    }

    @Override
    public int update(Data data) {
        return dataMapper.update(data);
    }

    @Override
    public int delete(String data_id) {
        return dataMapper.delete(data_id);
    }

    @Override
    public Data getById(String data_id) {
        return dataMapper.getById(data_id);
    }

    @Override
    public List<Data> getAll() {
        return dataMapper.getAll();
    }

    @Override
    public List<Data> getAllByFilter(Map<String, Object> map) {
        return dataMapper.getAllByFilter(map);
    }

//    @Override
//    public List<Data> getByFilterDataNull(Map<String,Object> map) {
//        return dataMapper.getByFilterDataNull(map);
//    }
//
//    @Override
//    public List<Data> getByFilterDataNotNull(Map<String,Object> map) {
//        return dataMapper.getByFilterDataNotNull(map);
//    }
//
//    @Override
//    public List<Data> getByTagName(String tagName) {
//        return dataMapper.getByTagName(tagName);
//    }


    @Override
    public List<Data> readDataFromTxt(String path) {
        return DataUtil.string2DataList(DataUtil.readStringDataFromTxt(path));
    }

    @Override
    public List<Data> filterByTagName(List<Data> data, String tagName) {
        return DataUtil.filterByTagName(data, tagName);
    }

    @Override
    public List<Data> filterDataNullWithTime(List<Data> data, String starttime, String endtime) {
        return DataUtil.filterDataNullWithTime(data, starttime, endtime);
    }

    @Override
    public List<Data> filterDataNull(List<Data> data) {
        return DataUtil.filterDataNull(data);
    }

    @Override
    public List<Data> filterDataNullTagName(List<Data> data, String tagName, String starttime, String endtime) {
        return DataUtil.filterDataNullTagName(data, tagName, starttime, endtime);
    }

    @Override
    public List<Data> filterDataNotNull(List<Data> data, String tagName, String starttime, String endtime) {
        return DataUtil.filterDataNotNull(data, tagName, starttime, endtime);
    }
}
